package com.xidian.zhiancloud.service.helpCenter;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xidian.zhiancloud.dao.DataDownloadMapper;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.exception.CustomizeException;
import com.xidian.zhiancloud.model.CommonProblem;
import com.xidian.zhiancloud.model.DataDownload;
import com.xidian.zhiancloud.qo.helpCenter.DataDownloadQO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DataDownloadService extends ServiceImpl<DataDownloadMapper, DataDownload> implements IService<DataDownload> {
    @Autowired
    private DataDownloadMapper dataDownloadMapper;

    public DataDownload getById(Long id) {
        DataDownload dataDownload = dataDownloadMapper.selectById(id);
        if (dataDownload == null) {
            throw new CustomizeException(GeneralResponseEnums.GET_FAILED);
        }
        return dataDownload;
    }

    public IPage<DataDownload> getListByQO(DataDownloadQO dataDownloadQO) {
        Page<DataDownload> page = new Page<>(dataDownloadQO.getCurrent(), dataDownloadQO.getSize());
        IPage<DataDownload> ans= dataDownloadMapper.getListByQO(page,dataDownloadQO);
        return ans;
    }
}
